<template>
	<!-- 添加弹框 -->
	<el-dialog  title="" width="50%"  :append-to-body="true" visible :show-close="false"  class="wrap" @close="cancel" >
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
	    <div class="bt">补课安排</div>
		<!--<el-form label-width="100px" class="form">
			<el-form-item label="老师" >
				<el-select v-model="vlsid" class="select-block">
					<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist"></el-option>
				</el-select></el-input>
			</el-form-item>
			<el-form-item label="开始时间">
				<el-date-picker  v-model="vbtime"  type="date" class="select-block" placeholder="选择日期" >  </el-date-picker>
			</el-form-item>
			<el-form-item label="学生">
				<el-tag>{{xsname}}</el-tag>

			</el-form-item>

		</el-form>-->
		<div class="form">
		<el-button type="" class="tj2" icon="el-icon-zoom-in" @click="componentsShow('edit',params)" >新添加补课</el-button>
			
		<el-button type="" class="tj" icon="el-icon-zoom-in" @click="componentsShow('add',params)" >加入现有安排</el-button>
		</div>
		<!--<el-button type="danger" class="submit"  @click="cancel">退出</el-button>
		<el-button type="primary"  @click="submit">保存</el-button>-->
		<AddComponent v-if="portComponents.add.toggle" @close="componentsHide" :params="portComponents.add.params"></AddComponent>
		<EditComponent v-if="portComponents.edit.toggle" @close="componentsHide" :params="portComponents.edit.params"></EditComponent>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	import AddComponent from './add'
	import EditComponent from '@/view/educa/lsbkap/edit'
	export default {
		props: ['params'],
		components: { AddComponent,EditComponent},
		data() {
			return {
				showchoselist: false,
				showarticle: false,
				xsname:'',
				vfxkcid: '',
				vfxkcidmc: '',
				vmc: '',
				vbtime:'',
//				vbtime2:'',
				vlsid: '',
				vcid: '',
				vjcid: '',
				vjcidmc: '',
				vlx: '',
				vypks: '',
				xzls:'',
				comboxlist: [],

				dialogTableVisible: true,
				xzlsList: [],
				portComponents: {
						/* 添加 */
						add: {
								type: 'add',
								toggle: false,
								params: '',
								data: {}
						},
						edit: {
								type: 'edit',
								toggle: false,
								params: '',
								data: {}
						},
					}
			}
		},
		created() {
//			console.log(this.params,898989)
			this.getcomboxlist()
			if(this.params.row.xs){
				this.xsname = this.params.row.xs
			}else if(this.params.row.name){
				this.xsname = this.params.row.name
			}else if(this.params.row.zwm){
				this.xsname = this.params.row.zwm
			}else{
				this.xsname = this.params.row.xsmc
			}
		},
		methods: {

			submit() {
				//检测
				this.$store.state.loading = true;
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
				var time2 = this.$.getLocalTimeNo0(Date.parse(this.vbtime2));
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					lsid:this.vlsid,
					bksj:time1,
//					jssj:time2,
					xsid:this.params.row.xsid,
					day:this.params.row.day,
					lx:this.params.row.lx,
					kslx:this.params.row.kslx,
					xxid:logininfo.xxid,
				});
				//执行
				this.axios.post(this.$store.state.api + 'bkap/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'bkap', cancel: false });
							this.$message.success(res.data.msg);
							this.$store.state.loading = false;
						} else {
							this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.danger("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},


			cancel() {
				this.$emit('close', { type: 'bkap', cancel: true })
			},
			getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				this.axios.get(this.$store.state.api + 'ls/getlslist', {
					params: {
						yhid: logininfo.id,
						xxid: logininfo.xxid
					}
				}).then(res => {
					let data = res.data.data;
					let list = data.list;
					this.comboxlist = list;
				}).catch(res => {
					this.searchLoading = false;
				})
			},
			componentsShow (type,data,list) { //显示组件
					for ( let i in this.portComponents ) {
							if (type == this.portComponents[i].type) {
									this.portComponents[i].toggle = true;
									this.portComponents[i].params = data;
									if (this.portComponents[i].data.type == 'single') {
											this.portComponents[i].data.index = data.row.id
									}else if(this.portComponents[i].data.type == 'multiple'){
											this.portComponents[i].data.index = this.multipleDelNum;
									}else{
											return;
									}
									return;
							}
					}
			},
			componentsHide (setting) { //关闭组件
          // this.loadinfo();
					// this.cancel();
					// if(setting.cancel == '11'){
					// 	this.$emit('close', { type: 'bkap', cancel: true })
					// }
					for ( let i in this.portComponents ) {

							if (setting.type == this.portComponents[i].type) {
									this.portComponents[i].toggle = false;
									if (!setting.cancel) {
//										 this.loadinfo();
									}
									return;
							}
					}
			}
		}
	}
</script>
<style lang="less" scoped >
	.wrap {
		.row{
			height:50px;
			line-height: 50px;
		}
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close{
				z-index: 10;
				position: absolute;
		}
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.input {
			width:280px;
			display: inline-block;
			margin-left: 10px;
		}
		.input1 {
			width: 210px;
			display: inline-block;
			margin-left: 10px;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			// width: 120px;
			// display: block;
			margin-left:20%;
			margin-top: 20px;
		}
		.wpfl {
			background: #fff;
			position: absolute;
			top: 5px;
			left: 5px;
		}
		.wpfl1 {
			width: 130%;
			background: #fff;
			position: absolute;
			top: 5px;
			left: -66px;
		}
		.form {
			/*width: 63%;*/
			text-align:center ;
			/*border-right: 1px solid #e8e8e8;*/
			/*text-align: left;*/
			margin-top: 20px;
			.select-block {
				width: 80%;
				display: block;
			}
			.select-block1 {
				width: 68%;
				// display: block;
			}
		}
		.tj{
			width: 200px;
			height: 100px;
			/*position: absolute;
			top: 35%;
			right: 5%;*/
		}
		.tj2{
			width: 200px;
			height: 100px;
			/*position: absolute;*/
			/*top: 35%;*/
			/*right: 5%;*/
		}
	}
</style>
